package com.dollar.producer_consumer.orderConsume;

import java.util.concurrent.ArrayBlockingQueue;

public class Main {
    public static void main(String[] args) {

        ProcessThreadPool.initPool();
        RequestQueue instance = RequestQueue.getInstance();
        ArrayBlockingQueue<String> queue1 = instance.getQueue(0);
        ArrayBlockingQueue<String> queue2 = instance.getQueue(1);
        ArrayBlockingQueue<String> queue3 = instance.getQueue(2);

        new Thread(() -> {
            while (true) {
                try {
                    queue1.put("1");
                    Thread.sleep(2000);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
            }
        }, "thread0").start();

        new Thread(() -> {
            while (true) {
                try {
                    queue2.put("2");
                    Thread.sleep(2000);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
            }
        }, "thread1").start();
        new Thread(() -> {
            while (true) {
                try {
                    //queue3.put("3");
                    Thread.sleep(2000);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
            }
        }, "thread2").start();
    }
}
